package com.xx.springboot.test.RabbitMQ;

import com.xx.springboot.test.RabbitMQ.work.Consumer;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;

/**
 * Created by xiaoxiunique on 2018-9-1.
 */
public class test {

    public static void main(String[] args) throws IOException, TimeoutException {
        // 测试rabbitmq 工作队列

        ExecutorService executorService = Executors.newCachedThreadPool();
        int count  = 1;
        for (int i = 0 ; i < 3 ; i++) {
            executorService.execute(() -> {
                Consumer consumer = new Consumer();
                try {
                    consumer.received("consumer" , 10 * count);
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (TimeoutException e) {
                    e.printStackTrace();
                }
            });
        }

        Consumer consumer = new Consumer();
        consumer.received("consumer1", 10000);

    }
}
